/////////////////////////
//
//

#ifndef __TASKQUEUE_H_INCLUDE__
#define __TASKQUEUE_H_INCLUDE__

#include "Lock.h"
#include "QueueThread.h"

////////////////////////////////
//
//
class IAsyncTask;
class IAsyncTaskCallback;


////////////////////////////////
//
//
class IAsyncTask
{
public:
	virtual int Type() = 0;
	virtual bool DoWork() = 0;
};


class IAsyncTaskCallback
{
public:
	virtual void OnTaskComplete(ULONGLONG AsyncTaskID, bool success, IAsyncTask* task) = 0;
};

class CAsyncWorker: public QueueThread
{
public:
	CAsyncWorker();

public:	
	virtual ~CAsyncWorker();

public:
	static CAsyncWorker& Instance();

protected:
	virtual void HandleMessage(	ULONGLONG ullParam_1 , ULONGLONG ullParam_2, ULONGLONG ullParam_3);

public:
	ULONGLONG AddTask(IAsyncTask* task, IAsyncTaskCallback* callback);

public:
	void ClearJobs();
	int GetJobCounts();

private:
	ULONGLONG m_nTaskId;
	CCriticalSectionX m_cs;
};

#endif